<template>
  <div class="regionRadio">
    <div :class="{'radio-item':true,active:activeIndex === index}" v-for="(item,index) in options" :key="index" @click="itemClick(item,index)">
      {{item.title}}
    </div>
  </div>
</template>

<script lang="ts">
import {Component, Vue} from 'vue-property-decorator';

@Component({
  components: {}
})
export default class RegionRadio extends Vue {
  private activeIndex = 0
  itemClick(item: any, index: number) {
    this.activeIndex = index
    this.$router.push(item.url)
    if(item.searchAreaLevel){
      this.$store.dispatch('saveAreaLevel',item.searchAreaLevel);
    }

  }
  private options = [
    {
      url: '/region/statistics',
      title: '统计管理',
    },
    {
      url: '/region/boundary',
      title: '县级边界核定',
    },
    {
      url: '/region/censusArea',
      title: '县以下区划调整',
      searchAreaLevel:7,
    },
    {
      url: '/region/regionSetting',
      title: '调查区划设置',
      searchAreaLevel:3,
    },
    {
      url: '/region/reportManager',
      title: '上报管理',
    }

  ]
  mounted(){
    const { fullPath } = this.$route;
    this.options.forEach((item,index)=>{
      if(fullPath.includes(item.url)){
        this.activeIndex = index;
      }
    })
  }
}
</script>
<style lang="scss" scoped>
.regionRadio{
  display: flex;
  align-items: center;
  gap: 10px;
  .radio-item{
    height: 24px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    text-align: center;
    color: #ffffff;
    border: 1px solid #ffffff;
    font-size: 13px;
    cursor: pointer;
    &.active{
      color: #26595d;
      border: 1px solid #26595d;
      background: #ffffff;
    }
  }
}
</style>
